function checkNumber(obj){
var x=obj.value
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
testresult=true
else{
obj.value = obj.value.substr(0,obj.value.length-1);
testresult=false
}
return (testresult)
}

function checkIsNumber(obj){
var x=obj.value
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
testresult=true
else
testresult=false
return (testresult)
}

function checkFormSearchForAgent (frm) {
	if (frm.pinphone.value.length<10) {
		alert ("Please enter 10 digits");
		frm.pinphone.focus;
		return false;
	}	
	return true;
}

function checkAddANI (frm) {
	if (!checkIsNumber(frm.ANI)) {
		alert ("Please enter 0-9 digit");
		frm.ANI.focus;	
		return false;
	} else 
	{
		if (frm.ANI.value.length<10) {
			alert ("Please enter 10 digits");
			frm.ANI.focus;
			return false;
		}
	}
	return true;
}

function checkAddSpeedDial (frm) {
	if (!checkIsNumber(frm.OUTGOING_NO)) {
		alert ("Please enter 0-9 digit");
		frm.OUTGOING_NO.focus;
		return false;
	} 
	return true;
}

function checkFormSearchForCS (frm) {
	if (frm.serialsearch.value.length==0 && frm.pinaccount.value.length==0 && frm.pinphone.value.length==0) {
		alert ("Please input search criteria!");
		frm.serialsearch.focus;
		return false;
	}	
	if (frm.pinaccount.value.length>0 && frm.pinaccount.value.length<12) {
		alert ("PIN, please enter 12 digits");
		frm.pinphone.focus;
		return false;
	}	
	if (frm.pinphone.value.length>0 && frm.pinphone.value.length<10) {
		alert ("Phone number, please enter 10 digits");
		frm.pinphone.focus;
		return false;
	}	
	return true;
}

function checkFormCallDetail (frm) {
	if (frm.pinaccount.value.length==0 && frm.pinphone.value.length==0) {
		alert ("Please input PIN or Phone Number!");
		frm.serialsearch.focus;
		return false;
	}	
	if (frm.pinaccount.value.length>0 && frm.pinaccount.value.length<12) {
		alert ("PIN, please enter 12 digits");
		frm.pinphone.focus;
		return false;
	}	
	if (frm.pinphone.value.length>0 && frm.pinphone.value.length<10) {
		alert ("Phone number, please enter 10 digits");
		frm.pinphone.focus;
		return false;
	}	
	return true;
}

function checkFormTransactionHistory (frm) {
	if (!checkIsNumber(frm.phonenumber)) {
		alert ("Please enter 0-9 digit");
		frm.phonenumber.focus;	
		return false;
	} else 
	{
		if (frm.phonenumber.value.length<10) {
			alert ("Please enter 10 digits");
			frm.phonenumber.focus;
			return false;
		}
	}
	return true;
}
